<%--
  Created by IntelliJ IDEA.
  User: lenovo
  Date: 2025/5/28
  Time: 23:03
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
    <title>商品详情</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <link type="text/css" rel="stylesheet" href="css/base.css">
    <link type="text/css" rel="stylesheet" href="css/common.css">
    <link type="text/css" rel="stylesheet" href="css/index.css">
    <script type="text/javascript" src="js/index.js" defer></script>
    <script type="text/javascript" src="js/goods.js" defer></script>


</head>
<body>

<jsp:include page="header.jsp"></jsp:include>

<div class="container goods-detail">

    <c:if test="${not empty gcs}">
        <script>
            alert("${gcs}");
        </script>
    </c:if>

<%--    左侧图片区域--%>
    <div class="goods-images">
        <%--大图--%>
        <div class="main-image" >
            <img alt="商品图片" src="${g.image1}" id="mainImage">
        </div>
        <%--缩略图--%>
        <div class="thumbnail-images">
            <img class="thumbnail active" alt="商品图片" src="${g.image1}" data-src="${g.image1}" >
            <img class="thumbnail" alt="商品图片" src="${g.image2}" data-src="${g.image2}">
            <img class="thumbnail" alt="商品图片" src="${g.image3}" data-src="${g.image3}">
        </div>
    </div>

<%--    右侧商品信息区域--%>
    <div class="goods-info-container">
<%--        商品信息--%>
        <div class="goods-info">
            <h2>${g.name}</h2>
            <p>${g.detail}</p>
            <p><strong>新旧程度：</strong>
                <c:choose>
                    <c:when test="${g.old_level==10}">全新</c:when>
                    <c:otherwise>${g.old_level}成新</c:otherwise>
                </c:choose>
            </p>
            <p><strong>商品类别：</strong>${g.category.name}</p>
            <p><strong>库存：</strong> <span class="inventory">${g.inventory}</span></p>
            <p><strong>价格：</strong> <span class="price">￥${g.price}</span></p>
            <p><strong>是否支持砍价：</strong>
                <span class="is_bargain">
                   <c:choose>
                       <c:when test="${g.is_bargain=='true'}">支持</c:when>
                       <c:otherwise>不支持</c:otherwise>
                   </c:choose>
                </span>
            </p>
        </div>
<%--        发布人信息--%>
        <div class="seller-info">
            <img src="${pageContext.request.contextPath}${g.user.avatar}" alt="发布人头像">
            <span class="seller-name">${g.user.nickname}</span>
        </div>
<%--        按键操作--%>
        <div class="action-buttons">
            <form action="goods_want" method="post" style="display:inline-block;" class="want-btn">
                <input type="hidden" name="id" value="${g.id}">
                <button type="submit" class="want-btn">想要</button>
            </form>
            <form action="goods_collect" method="post" style="display:inline-block;" class="collect-btn">
                <input type="hidden" name="goodsid" value="${g.id}">
                <button type="submit" class="collect-btn">收藏</button>
            </form>
        </div>
    </div>
</div>

</body>
</html>
